import { createSlice } from '@reduxjs/toolkit'
import { RootState } from './store'

const initialState = {
	selectedLanguage: 'English'
}

export const settingsSlice = createSlice({
	name: 'settings',
	initialState,
	reducers: {
		selectLanguage: (state, action) => {
			// immer
			state.selectedLanguage = action.payload
		}
	}
})

export const selectedLanguage = (state: RootState) => state.settings.selectedLanguage

export const { selectLanguage } = settingsSlice.actions
export const settingsReducer = settingsSlice.reducer
